<?php

namespace App\Admin\Validate\Financial;

use App\Common\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class FinancialRate extends BaseValidate
{

    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];


    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'pay_type_id'=>'required|integer',
                'money_start'=>'required|integer|gt:0',
                'money_end'=>'required|integer|gt:0',
                'val_type'=>'required|in:1,2',
            ];
            $this->message = [
                'pay_type_id.required' => '收款方式未选择',
                'pay_type_id.integer' => '收款方式参数错误',
                'pay_type_id.gt' => '收款方式参数错误',

                'money_start.required' => '开始金额不能为空',
                'money_start.integer' => '开始金额需大于0',
                'money_start.gt' => '开始金额需大于0',

                'money_end.required' => '结束金额不能为空',
                'money_end.integer' => '结束金额需大于0',
                'money_end.gt' => '结束金额需大于0',

                'val_type.required' => '请选择费率类型',
                'val_type.in' => '费率类型参数错误',
            ];
        }elseif($doaction=='edit') {
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'pay_type_id'=>'required|integer',
                'money_start'=>'required|integer|gt:0',
                'money_end'=>'required|integer|gt:0',
                'val_type'=>'required|in:1,2',
            ];
            $this->message = [
                'id.required' => '账户参数错误',
                'id.integer' => '账户参数错误',
                'id.gt' => '账户参数错误',
                'pay_type_id.required' => '收款方式未选择',
                'pay_type_id.integer' => '收款方式参数错误',
                'pay_type_id.gt' => '收款方式参数错误',

                'money_start.required' => '开始金额不能为空',
                'money_start.integer' => '开始金额需大于0',
                'money_start.gt' => '开始金额需大于0',

                'money_end.required' => '结束金额不能为空',
                'money_end.integer' => '结束金额需大于0',
                'money_end.gt' => '结束金额需大于0',

                'val_type.required' => '请选择费率类型',
                'val_type.in' => '费率类型参数错误',
            ];
        }
    }
}
